{% extends "admin/base.html" %}
{% block hscript %}
	<script type="text/javascript" src="themes/{{site.theme}}/style/jquery.min.js"></script>
    <script type="text/javascript" src="themes/{{site.theme}}/style/jquery.form.js"></script>
{% endblock %}
{% block nav %}
			<a href="?a=Post">All posts</a>
			<a href="?a=Post&d=create">Write post</a>
{% endblock %}
{% block content %}
<form id="postForm" action="?a=Post" method="post">
	 <div class="wrap">
      <h2>Publish Post</h2>
      <div id="poststuff">

<div id="submitlink" class="submitbox">

<div id="previewview"></div>
<h3>Category</h3>
<div class="inside">

<p style="height:120px;overflow-y:auto">
                    {%for cat in categories%}
                       <input type="checkbox" name="categories" tabindex="7" value="{{cat.id}}" {%if post.categoryIds|contain:cat.id %}checked="checked"{%endif%}/>{{cat.name}}<br>
                    {%endfor%}
</p>

</div>
<p class="submit">
<input type="submit" tabindex="9" value="Save" name="save" class="button button-highlighted"/>
  <input type="checkbox" style="margin-left:10px;" tabindex="8" value="publish" name="publish" class="button button-highlighted" {%if post.published %}checked="checked"{%endif%}/>Published
</p>

</div>

<div id="post-body2">

<div id="titlediv">
<h3>Title</h3>
<div id="titlewrap">
	<input id="title" type="text" id="title" value="{{post.title}}" tabindex="1" size="60" name="title"/>
</div>
</div>

<div class="clear"></div>
<div class="stuffbox">
<h3>Slogan</h3>
<div class="inside">
	<input id="slogan" type="text" value="{{post.slogan}}" tabindex="3" size="40" name="slogan"/><br/>
</div>
</div>

<div class="clear"></div>
<div class="stuffbox">
<h3>Tags</h3>
<div class="inside">
	<input id="tags" type="text" value="{{post.tagNames}}" tabindex="4" size="40" name="tagNames"/><br/>
</div>
</div>

<div class="clear"></div>
<div class="stuffbox">
<h3>Excerpt</h3>
<div class="inside">
	<textarea id="excerpt" style="width: 675px;" cols="38" tabindex="5" name="excerpt">{{post.excerpt}}</textarea><br/>
</div>
</div>

<div class="clear"></div>
<div class="stuffbox">
<h3>Reload</h3>
<div class="inside">
	<input id="source" type="text" value="{{post.source}}" tabindex="6" size="94" name="source"/><br/>
</div>
</div>

	<input type="hidden" value="{{post.id}}" name="id"/>
	<input type="hidden" name="d" value="update" />
</div>
</div>	
</div>
</form>
{% endblock  %}
{% block bscript %}    
<script type="text/javascript">
$(function() { 
    var options = {
    	    dataType: 'json',
    	    success : function(data) {
	    			var hmd = $("#hiddenMessage");
	    			if (data.type == "error") {
	    				hmd.html("<div class='error'>" + data.message + "</div>");
	    			} else {
	    				hmd.html("<div class='info'>" + data.message + "</div>");
	    			}
	    			hmd.show().focus();
    			},
    	};
    	$("#postForm").ajaxForm(options);
    }
);
</script>
{% endblock %}